import Vue from 'vue'
import App from './App'
import Vuex from 'vuex'
Vue.use(Vuex)
import store from './store'
import cuCustom from './colorui/components/cu-custom.vue'
import BackTop from './colorui/components/BackTop.vue'
import LimeTips from "./colorui/components/Tips.vue"
import zytInput from '@/colorui/components/input.vue'
import graceChecker from './colorui/components/form/graceChecker.js'
// import style from '@/uni.scss';
Vue.prototype.$graceChecker = graceChecker
Vue.component('cu-custom',cuCustom)
Vue.component('back-top',BackTop)
Vue.component('lime-tips',LimeTips)
Vue.component('zyt-input',zytInput)
Vue.config.productionTip = false
App.mpType = 'app'
Vue.prototype.$bus = new Vue()
//main.js
import {req} from "@/service/config.js"; //文件路径请换成本地路径
let IP = uni.getStorageSync("IP") || 'http://60.173.239.156';
let PORT = uni.getStorageSync("PORT") || '8443';
req.defaultData.baseUrl = IP + ":" + PORT + '/api'; //公共请求基础地址、
// req.defaultData.baseUrl = IP + ":" + PORT; //公共请求基础地址
req.defaultData.header.token = uni.getStorageSync("token") || "0000-1111-2222-3333" //设置token值
//全局请求前置拦截
req.defaultData.beforeAjax = (res)=>{
    // console.log(bf)
}
//全局请求后置拦截
req.defaultData.afterAjax = (res)=>{
	if(res.msg == '请先登陆') {
		uni.showModal({
		    title: '提示',
		    content: '登录已过期！请重新登录',
		    success: (res) => {
		        if (res.confirm) {
					global.falg = true
					setTimeout(() => {
						uni.reLaunch({
						    url: '/pages/login/login'
						});
					},500)
		        } else if (res.cancel) {
					
		        }
		    }
		});
	}
	return res;
}
Vue.prototype.$http = {req}; //挂载在原形上

const app = new Vue({
    ...App,
    store
})
app.$mount()
